/* gl_lines.c */


#include <GL/glut.h>


void drawBox(void)
{
  glLineWidth(2.0);
  glBegin(GL_LINE_LOOP);
  glVertex2f( 200.0,   200.0);
  glVertex2f( 280.0,   200.0);
  glVertex2f( 280.0,   260.0);
  glVertex2f( 200.0,   260.0);
  glEnd();
  
  /* simulate round corners */
  glPointSize(2.0);
  glBegin(GL_POINTS);
  glVertex2f( 200.0, 200.0);
  glVertex2f( 280.0, 200.0);
  glVertex2f( 280.0, 260.0);
  glVertex2f( 200.0, 260.0);
  glEnd();
   

  glFlush();
}

void display(void)
{
  glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
  drawBox();
  glutSwapBuffers();
}

void init(void)
{
  glClearColor(0.5, 0.5, 0.5, 0.0);
  glMatrixMode (GL_PROJECTION);
  glLoadIdentity ();
  /* This sets origin to top-left as per Processing */
  glOrtho (0, 640, 480, 0, 0, 1);
  glMatrixMode (GL_MODELVIEW);
  glLoadIdentity();
  /* Folklore - make coordinates exact pixels */
  glTranslatef(0.375, 0.375, 0); 
}

int main(int argc, char **argv)
{
  glutInit(&argc, argv);
  glutInitWindowSize(640,480);
  glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH);
  glutCreateWindow("Geom prim");
  glutDisplayFunc(display);
  init();
  glutMainLoop();
  return 0;
}
